package flst.ipiweb.proxy;

import java.util.List;

import flst.ipiweb.process.ArticleProcess;
import flst.ipiweb.transverse.Article;
import flst.ipiweb.transverse.IPIWebException;

public class ArticleProxy {

	private ArticleProcess part;
	private boolean droits = false;
	
	public ArticleProxy() {
		part = new ArticleProcess();
	}
	
	public boolean getDroits() {
		return droits;
	}
	
	public void setDroits(boolean droits) {
		this.droits = droits;
	}
	
	public List<Article> getAllArticle() throws IPIWebException{
		if (droits){
			return part.getAllArticle();
		}
		else{
			return null;
		}
	}
	
	public Article getArticleById(int id) throws IPIWebException{
		if (droits){
			return part.getArticleById(id);
		}
		else{
			return null;
		}
	}
	
	public void createArticle(Article art) throws IPIWebException{
		if(droits){
			part.CreateArticle(art);
		}
	}
	
	public void updateArticle(Article art) throws IPIWebException{
		if(droits){
			part.UpdateArticle(art);
		}
	}
	
	public void desactiverArticle(int id) throws IPIWebException{
		if(droits){
			part.DesactiverArticle(id);
		}
	}
	
	public int generateId() throws IPIWebException{
		if(droits){
			return part.GenerateId();
		}
		else{
			return -1;
		}
	}
	
	public Boolean checkArticleById(int id) throws IPIWebException{
		if(droits){
			return part.checkArticleById(id);
		}
		else{
			return null;
		}
	}
}
